package com.asuka.eva.config;

import com.asuka.eva.dao.test.EasySqlInjector;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author ZuoWei Jin, 13504284153
 * @version 1.0
 * @description MyBatisPlus的配置类
 * @since 2021/11/5 23:26
 */
@Configuration
public class MyBatisPlusConfig extends DefaultSqlInjector {
    @Bean("easySqlInjector")
    @Primary
    public EasySqlInjector easySqlInjector() {
        return new EasySqlInjector();
    }

    /**
     * 解决MyBatisPlus分页失效得问题
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
